home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / NR4MAIL.C < prev    next >
C/C++ Source or Header  |  1997-07-30  |  2KB  |  71 lines

  1. /* NETROM mailbox interface
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  *
  4.  *  May '91 Bill Simpson
  5.  *      move to separate file for compilation & linking
  6.  */
  7. #include "global.h"
  8. #ifdef NETROM
  9. #ifndef MSDOS
  10. #include "ctype.h"
  11. #endif
  12. #include "commands.h"
  13. #include "proc.h"
  14. #include "netrom.h"
  15. #include "session.h"
  16. #include "mailbox.h"
  17. #include "nr4mail.h"
  18.  
  19. #if !defined(_lint)
  20. static char rcsid[] OPTIONAL = "$Id: nr4mail.c,v 1.13 1997/07/31 00:44:20 root Exp root $";
  21. #endif
  22.  
  23. static int Nrsocket = -1;
  24.  
  25.  
  26. int
  27. nr4start (int argc OPTIONAL, char *argv[] OPTIONAL, void *p OPTIONAL)
  28. {
  29. int s;
  30.  
  31.     if (Nrsocket != -1)
  32.         return -1;
  33.  
  34.     ksignal (Curproc, 0);    /* Don't keep the parser waiting */
  35.     server_disconnect_io ();
  36.     chname (Curproc, "NETROM listener");
  37.     Nrsocket = socket (AF_NETROM, SOCK_SEQPACKET, 0);
  38.     /* bind() is done automatically */
  39.     if (listen (Nrsocket, 1) == -1) {
  40.         close_s (Nrsocket);
  41.         Nrsocket = -1;
  42.         return -1;
  43.     }
  44.     for (;;) {
  45.         if ((s = accept (Nrsocket, NULLCHAR, NULLINT)) == -1)
  46.             break;    /* Service is shutting down */
  47. #ifdef MAILBOX
  48.         /* Spawn a server */
  49.         if (newproc ("pbbs", 2048, pbbs_incom, s, (void *) NR4_LINK, NULL, 0) == NULLPROC)
  50.             close_s (s);
  51. #else
  52.         if (newproc ("TTYLINK Server", 2048, ttylhandle, s, (void *) NR4_LINK, NULL, 0) == NULLPROC)
  53.             close_s (s);
  54. #endif
  55.     }
  56.     close_s (Nrsocket);
  57.     Nrsocket = -1;
  58.     return 0;
  59. }
  60.  
  61.  
  62. int
  63. nr40 (int argc OPTIONAL, char *argv[] OPTIONAL, void *p OPTIONAL)
  64. {
  65.     close_s (Nrsocket);
  66.     Nrsocket = -1;
  67.     return 0;
  68. }
  69.  
  70. #endif /* NETROM */
  71.